package com.small.admin.entity;

import com.small.common.base.ConstantPattern;
import com.small.common.util.val.group.ValAdd;
import com.small.common.util.val.group.ValUpdate;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * 作者: fenny
 * 邮箱: 893146555@qq.com
 * 时间: 2017-10-17 15:28:29
 * 描述: 管理员信息
 */
@Data
@Table(name = "t_admin")
public class Admin implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
	@NotNull(groups = ValUpdate.class)
    private Long id;
	
	//名称
	@NotEmpty(groups = {ValAdd.class})
	@Length(min = 1, max = 30, groups = {ValAdd.class, ValUpdate.class})
	@Column(name = "name")
    private String name;
	
	//账号
	@Pattern(regexp = ConstantPattern.VAL_ACCOUNT,groups = {ValAdd.class})
	@Column(name = "account")
    private String account;
	
	//密码默认888888
	@Length(min = 6, max = 30, groups = {ValAdd.class})
	@Column(name = "password")
    private String password;
	
	//登录错误次数
	@Column(name = "login_error")
    private Integer loginError;
	
	//1是超级管理员
	@Column(name = "is_system")
    private Integer isSystem;
	
	//邮箱
	@Length(max = 30, groups = {ValAdd.class, ValUpdate.class})
	@Column(name = "email")
    private String email;
	
	//电话
	@Length(max = 20, groups = {ValAdd.class, ValUpdate.class})
	@Column(name = "phone")
    private String phone;
	
	//手机
	@Length(max = 20, groups = {ValAdd.class, ValUpdate.class})
	@Column(name = "mobile")
    private String mobile;
	
	//状态0关闭,1开启,2临时封号
	@Min(value = 0, groups = {ValAdd.class, ValUpdate.class})
	@Max(value = 2, groups = {ValAdd.class, ValUpdate.class})
	@Column(name = "state")
    private Integer state;
	
	//state=2封号时间
	@Column(name = "seal_date")
    private Long sealDate;
	
	@Column(name = "cid")
    private Long cid;
	
	@Column(name = "ctime")
    private Long ctime;
	
	@Column(name = "uid")
    private Long uid;
	
	@Column(name = "utime")
    private Long utime;

}
